<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.1</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style type="text/css">
    .layui-transfer-box{overflow-y: auto;}
    </style>

  </head>
  <body>
    <div class="x-body">
        <form class="layui-form">
          <input type="hidden" name="id" value="{$admins.id}">
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  <span class="x-red">*</span>员工姓名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="name" name="name" value="{$admins.name}" required="" lay-verify="required|name"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>员工姓名
              </div>
          </div>
          <div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  联系方式
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="phone" name="phone" value="{$admins.phone}"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>用户名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="username" name="username"  value="{$admins.username}" required="" lay-verify="required|username"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>将会成为您唯一的登入名
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="L_pass" class="layui-form-label">
                  <span class="x-red"></span>密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="password" required="" lay-verify="pass"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red"></span>不填代表不修改,建议6到16个字符
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                  <span class="x-red"></span>确认密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" name="repass" id="L_repass" required=""
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red"></span>不填代表不修改,建议6到16个字符
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                  <span class="x-red"></span>入职时间
              </label>
              <div class="layui-input-inline">
                    <input type="text" class="layui-input" value="{:date('Y-m-d',$admins.join_time)}" id="join_time" name="join_time" autocomplete="off" placeholder="入职时间">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label" style="width:90px">
                    <span class="x-red"></span>每日最大录入量
              </label>
              <div class="layui-input-inline">
                    <input type="text" class="layui-input" value="{$admins.max_count_day}" id="max_count_day" name="max_count_day" autocomplete="off" placeholder="每日最大录入量">
              </div>
          </div>
          {if condition="session('group_id','','admin') eq 1"}
          <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>角色</label>
            <div class="layui-input-inline">
              <select name="group_id" lay-verify="required" lay-filter="group_id">
                {volist name="groupRes" id="group"}
                <option value="{$group.id}" {if condition="$admins['group_id'] eq $group['id']"}selected="selected"{/if}>{$group.title}</option>
                {/volist}
              </select>
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">岗位</label>
            <div class="layui-input-inline" style="width:auto">
                <input type="radio" name="job" value="见习一个月" title="见习一个月">
                <input type="radio" name="job" value="见习二个月" title="见习二个月">
                <input type="radio" name="job" value="见习三个月" title="见习三个月">
                <input type="radio" name="job" value="营销专员" title="营销专员">
                <input type="radio" name="job" value="高级营销专员" title="高级营销专员">
            </div>
          </div>
          {/if}
          {if condition="session('group_id','','admin') eq 1 || (session('group_id','','admin') eq 5 && session('uid','','admin') eq $admins['id']) "}
          <div class="layui-form-item">
            <label class="layui-form-label">小组名称</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$admins.group_name}" id="group_name" name="group_name" autocomplete="off" placeholder="小组名称">
            </div>
          </div>
          <!--<div class="layui-form-item">-->
          <!--  <label class="layui-form-label">小组颜色</label>-->
          <!--  <div class="layui-input-inline">-->
          <!--      <input type="color" class="layui-input" value="{$admins.group_color}" id="group_color" name="group_color" autocomplete="off" placeholder="小组颜色">-->
          <!--  </div>-->
          <!--</div>-->
          
          
          <div class="layui-form-item" id="group-transfer-div" style="display:none;height:310px;">
              <label class="layui-form-label"><span class="x-red">*</span>小组成员</label>
              <div class="layui-input-block">
                <div id="group-transfer" class="group-transfer" ></div>
              </div>
          </div>

          
          {/if}

          <div class="layui-form-item">
              <label class="layui-form-label"><span class="x-red">*</span>状态</label>
              <div class="layui-input-block">
                <input type="radio" name="status" {if condition="$admins['status'] eq 1"}checked="checked"{/if} value="1" lay-skin="primary" title="启用" checked="">
                <input type="radio" name="status" {if condition="$admins['status'] eq 0"}checked="checked"{/if} value="0" lay-skin="primary" title="禁用">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="edit" lay-submit="">
                  确定编辑
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer','transfer','util','jquery','laydate'], function(){
          $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer
          ,transfer = layui.transfer
          ,util = layui.util
          ,laydate = layui.laydate;

          {if condition="$admins['group_id'] eq 5 || (session('group_id','','admin') eq 5 && session('uid','','admin') eq $admins['id'])"}
          $('#group-transfer-div').show();
          transferInit();
          {/if}
          laydate.render({
            elem: '#join_time'
          });
          
          util.event('lay-transferactive', {
            getData: function(othis){
              var getData = transfer.getData('group-transfer');
              console.log(getData);
              layer.alert(JSON.stringify(getData)); 
            }
          });
          form.on('select(group_id)', function(data){
            if(data.value == 5)
            {
              $('#group-transfer-div').show();
              transferInit();
            }
            else
            {
              $('#group-transfer-div').hide();
            }
          }); 
          function transferInit()
          {
              var data = {$staffList};
              transfer.render({
                elem: '#group-transfer'
                ,title: ['可选成员', '已选组员']
                ,data: data
                ,id: 'group-transfer'
                ,showSearch: true
                ,value: [ {$admins['group_members']}]
                //,width: 150 
                ,height: 310 
                ,text: {
                  none: '无'
                  ,searchNone: '无匹配人员'
                }
              })
          }

          form.on('submit(edit)', function(data){
            var transferData;
            {if condition="$admins['group_id'] eq 5 || (session('group_id','','admin') eq 5 && session('uid','','admin') eq $admins['id'])"}
            var transferData = transfer.getData('group-transfer');
            transferData = JSON.stringify(transferData);
            {/if}
            $.ajax({
                type:'POST',
                dataType:'json',
                data:{data:data.field,group_members:transferData},
                url:"{:url('Admin/edit')}",
                success:function(obj){
                  layer.alert(obj.msg, {icon: obj.icon},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    // 可以对父窗口进行刷新 
                    x_admin_father_reload();
                  });
                }
            });
            return false;
          });

        });
    </script>
  </body>

</html>